import { Action } from '@ngrx/store';

import { District, DistrictOptions, UserLocation } from '../../../ngx-ol/models';

export enum DistrictActionTypes {
    LOAD_DISTRICTS = '[Districts] Load Districts',
    LOAD_DISTRICTS_FAIL = '[Districts] Load Districts Fail',
    LOAD_DISTRICTS_SUCCESS = '[Districts] Load Districts Success',
    SELECT_DISTRICT = '[Districts] Select District',
    SELECT_DISTRICT_LOAD_FAIL = '[Districts] Select District Load Fail',
    SELECT_DISTRICT_LOAD_SUCCESS = '[Districts] Select District Load Success',
    AUTO_LOCATE_DISTRICT = '[Districts] Auto Locate District',
    AUTO_LOCATE_DISTRICT_FAIL = '[Districts] Auto Locate District Fail',
    AUTO_LOCATE_DISTRICT_SUCCESS = '[Districts] Auto Locate District Success',
}



export class LoadDistricts implements Action {
    readonly type = DistrictActionTypes.LOAD_DISTRICTS;
}

export class LoadDistrictsFail implements Action {
    readonly type = DistrictActionTypes.LOAD_DISTRICTS_FAIL;
    constructor(public payload: any) {}
}

export class LoadDistrictsSuccess implements Action {
    readonly type = DistrictActionTypes.LOAD_DISTRICTS_SUCCESS;
    constructor(public payload: District[]) {}
}

export class SelectDistrict implements Action {
    readonly type = DistrictActionTypes.SELECT_DISTRICT;
    constructor(public payload: string) {}
}

export class SelectDistrictLoadFail implements Action {
    readonly type = DistrictActionTypes.SELECT_DISTRICT_LOAD_FAIL;
}

export class SelectDistrictLoadSuccess implements Action {
    readonly type = DistrictActionTypes.SELECT_DISTRICT_LOAD_SUCCESS;
    constructor(public payload: UserLocation) {}
}

export class AutoLocateDistrict implements Action {
    readonly type = DistrictActionTypes.AUTO_LOCATE_DISTRICT;
}

export class AutoLocateDistrictFail implements Action {
    readonly type = DistrictActionTypes.AUTO_LOCATE_DISTRICT_FAIL;
}

export class AutoLocateDistrictSuccess implements Action {
    readonly type = DistrictActionTypes.AUTO_LOCATE_DISTRICT_SUCCESS;
    constructor(public payload: UserLocation) {}
}


export type DistrictAction 
    = LoadDistricts 
    | LoadDistrictsFail 
    | LoadDistrictsSuccess
    | SelectDistrict
    | SelectDistrictLoadFail
    | SelectDistrictLoadSuccess
    | AutoLocateDistrict
    | AutoLocateDistrictFail
    | AutoLocateDistrictSuccess;